/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package compilador.analisadorLexico;

/**
 *
 * @author matheus.mcas
 */
public enum PalavraReservada {

    BREAK("break"), CLASS("class"),
    
    CONST("const"), ELSE("else"),
    
    IF("if"), NEW("new"),
    
    READ("read"), RETURN("return"),
    
    VOID("void"), WHILE("while"),  WRITE("write"),
    
    CHAR("char"), INT("int");
    
    private String reservedWord;

    private PalavraReservada(String reservedWord) {
        this.reservedWord = reservedWord;
    }

    private String getReservedWord() {
        return reservedWord;
    }
    
    
    public static PalavraReservada checkRW(String lexema) {

        for(PalavraReservada rw: PalavraReservada.values()){
            
            if(rw.getReservedWord().compareToIgnoreCase(lexema) == 0)
                return rw;
        }

        return null;
    }

    @Override
    public String toString() {
        return this.reservedWord;
    }
    
    
}
